package co.edu.udem.service.subject;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import co.edu.udem.dao.SubjectDao;
import co.edu.udem.domain.Subject;
import co.edu.udem.service.GenericDTO;
import co.edu.udem.service.GenericService;

/**
 * @since 25/07/2012
 */
@Service("subjectService")
public class SubjectService implements GenericService {

	@Autowired
	private SubjectDao subjectDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see co.edu.udem.service.GenericService#getObjectList(java.util.Date,
	 * java.lang.String[][], java.lang.Object[])
	 */
	public List<GenericDTO> getObjectList(Date serviceDate, String[][] orderBy,
			Object... params) {
		List<Object[]> subjectList = (List<Object[]>) subjectDao.getObjectList(serviceDate,
				orderBy, params);
		List<GenericDTO> subjectDTOList = SubjectDTO
				.populateDTOList(subjectList);
		return subjectDTOList;
	}

	public List<Subject> getSubjectListByTeacherCode(String teacherCode) {
		return subjectDao.getSubjectListByTeacherCode(teacherCode);
	}

	public void addSubject(Subject subject) {
		subjectDao.addSubject(subject);
	}
	
	public Subject getSubjectById(String subjectCode) {
		return subjectDao.getSubjectById(subjectCode);
	}
	
	public void delete(String subjectCode) {
		subjectDao.delete(subjectCode);
	}

}
